package com.jxt.myjxtmanager.ui.presenter;

import android.content.Context;

import com.jxt.myjxtmanager.db.Subject;
import com.jxt.myjxtmanager.ui.inter.SubjectInter;
import com.jxt.myjxtmanager.ui.model.SubjectMo;
import com.jxt.myjxtmanager.views.CustomProgressDialog;

/**
 * Created by qm on 2017/3/7 0007.
 */
public class SubjectPresenter implements SubjectMo.OnFindAllDataListener {
    private final CustomProgressDialog dialog;
    private SubjectMo subjectMo;
    private SubjectInter inter;

    public SubjectPresenter(Context context, SubjectInter inter) {
        this.inter = inter;
        subjectMo = new SubjectMo(context);
        subjectMo.setOnFindAllDevicesListener(this);
        dialog = new CustomProgressDialog(context, "");
    }

    public Subject getQueryList(String subjectName, int position) {
        return subjectMo.getQueryList(subjectName, position);
    }

    public void dismissDialog() {
        if (dialog != null) {
            dialog.dismiss();
        }
    }

    public void RequestData() {
        if (dialog != null) {
            dialog.showDialog();
        }
        subjectMo.RequestData();
    }

    @Override
    public void onFindSuccess() {
        inter.setMyAdapter();
    }

    @Override
    public void onFailure() {

    }

    @Override
    public void onError() {

    }
}
